package com.kqb.controller;

import com.kqb.common.controller.base.BaseController;
import com.kqb.common.domain.AjaxResult;
import com.kqb.pojo.dto.RoleDto;
import com.kqb.service.IRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 杉果树皮
 * @date 2025/2/17 20:14
 * @description:
 */
@RestController
@RequestMapping("/api")
@Api(tags = "角色")
public class RoleController extends BaseController {
    @Autowired
    private IRoleService iRoleService;

    @PostMapping("/role")
    @ApiOperation("添加角色")
    public AjaxResult save(@RequestBody RoleDto roleDTO) {
        return iRoleService.save(roleDTO);
    }


    @DeleteMapping("/role/{id}")
    @ApiOperation("删除角色")
    public AjaxResult deleteById(@PathVariable("id") Integer id) {
        return iRoleService.deleteById(id);
    }

    @GetMapping("/role")
    @ApiOperation("查看所有角色")
    public AjaxResult selectByPage(RoleDto roleDTO) {
        return iRoleService.selectByPage(roleDTO);
    }


    @GetMapping("/role/all")
    @ApiOperation("查看所有角色")
    public AjaxResult selectAll() {
        return iRoleService.selectAll();
    }
}
